﻿@using KRM.Core
@using KRM.Core.Library
@model IEnumerable<vCustomerCallback>
@{
    ViewBag.Title = "Frontpage Banner Management";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/js/intranet/AjaxObject.js"></script>
<script src="~/js/intranet/customercallbackscare.js"></script>
<form action="/intranet/customercallbackscare" method="GET">
    <br />
    <input class="hdfDel" id="hdfDel" type="hidden" value="" />
    <div class="">
        <h3>Customer Callbacks - @Request["type"]</h3>
        View:
        <select id="WhatToSee" name="WhatToSee">
            <option value="0">Outstanding Callbacks</option>
            <option value="1" @(Request["WhatToSee"] == "1" ? "selected=selected" : "")>Completed Callbacks</option>
        </select>
        <input type="submit" value="OK" class="btn btn-primary" style="margin-bottom: 10px;">
        <input type="hidden" name="type" value="@Request["type"]" />
        <br />
        <br />
        Callback List:<br />
    </div>
</form>
<div id="outstandingArea">
    <style>
        #outstandingTable td {
            border: 1px solid #000;
            padding: 2px;
        }
    </style>
    <table cellpadding="0" cellspacing="0" id='outstandingTable' style='border: 1px solid #000' width='100%'>

        @if (Request["WhatToSee"] == "1")
        {
            <tr align="center" style='background-color: #C00; color: #FFF; font-weight: bold;'>
                <td>Product</td>
                <td>Request Time</td>
                <td>Customer's Name</td>
                <td>Customer's Email</td>
                <td>Customer's Telephone</td>
                <td>Date Completed</td>
                <td>Action</td>
                <td>Completed By</td>
            </tr>

        }
        else
        {                <tr align="center" style='background-color: #C00; color: #FFF; font-weight: bold;'>
            <td style='width: 50px; display: block; height: 58px;'>
                <input type='button' value='Delete' onclick='deleteAll()' style='position: fixed; margin: 12px 0 0 -27px; border-color: rgba(82, 168, 236, 0.8); outline: 0; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);' /></td>
            <td>Product</td>
            <td>Site</td>
            <td>Request Time</td>
            <td>Customer's Name</td>
            <td>Preferred Time</td>
            <td>Customer's Email</td>
            <td>Customer's Telephone</td>
            <td>Callback Complete?</td>
            <td>Use for shed</td>
        </tr>

        }
        @foreach (var item in Model)
        {
            string siteAddress = item.StoreDomain;
            string productId = item.productID.ToString();
            string productImage = siteAddress + "/images/products/" + item.ProductImage;
            string productName = "";
            if (productId == "-1")
            {
                productName = "General Enquiry";
            }
            else
            {
                productName = item.ProductName;
            }
            string customerName = item.customerName;
            string customerEmail = item.customerEmail;
            string customerTelephone = item.customerTelephone;
            string requestTime = ((item.requestDateTime != null) ? item.requestDateTime.ToString() : "");
            string completeTime = ((item.completeDateTime != null) ? item.completeDateTime.ToString() : "");
            string completedBy = (item.completedBy ?? "");
            string callbackTime = item.CallbackTime;
            string orderStatus = item.OrderStatus;
            string question = item.Question;
            string type = Request["type"];
            //format htmlEmail to control the size of the email in the table cell

            if (item.callbackComplete.ToString().ToLower() == "1")
            {
            <tr style="text-align: center">
                <td>@productName</td>
                <td>@requestTime </td>
                <td>@customerName </td>
                <td>@customerEmail </td>
                <td>@customerTelephone </td>
                <td>@completeTime </td>
                <td>@orderStatus </td>
                <td>@completedBy </td>
            </tr>
            }
            else
            {
            <tr style="text-align: center">
                <td>
                    <input type='checkbox' id='del@(item.callbackID)' value='@item.callbackID' class='chkDel'/></td>
                <td>@if (productId == "-1")
                    {
                    <div style='margin: 50px 0;'>General Enquiry</div>
                    }
                    else
                    {
                    <a href='@siteAddress /Product.aspx?prodID=@productId '>
                        <img style='border: 0; width: 150px;' src='@productImage'/>
                        <br />
                        @productName </a>
                    }
                </td>
                <td>@siteAddress </td>
                <td>@requestTime</td>
                <td>@customerName</td>
                <td>@callbackTime </td>
                <td><a href='mailto:@customerEmail ' title='@customerEmail '>Email Customer</a> </td>
                <td>@customerTelephone </td>
                <td>
                    <button type='button'  onclick="completeCallback('@item.callbackID.ToString()' , '@item.callbackID' , '@type' , 'del');" style='margin:10px 0' >Delete</button>
                    <select id='ResultingAction@(item.callbackID)'>
                        <option>--Choose Action Taken--</option>
                        <option value='Order Placed'>Order Placed</option>
                        <option value='Order Not Placed'>Order Not Placed</option>
                        <option value='Ordering Later Online'>Ordering Later Online</option>
                        <option value='RDM Added'>RDM Added</option>
                        <option value='Issue Resolved'>Issue Resolved</option>
                        <option value='Delivery Enquiry'>Delivery Enquiry</option>
                    </select><br />
                    <button type='button' onclick="completeCallback('@item.callbackID', '@item.callbackID' , '@type' ,'')"  style='margin:10px 0' >Complete</button>
                </td>
                <td>@question </td>
            </tr>
            }
        }

    </table>
    ";
</div>
